﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace IPSC
{
    class XmlQC
    {
        private XmlDocument writer;
        private XmlNode declaration;
        //----------------------------
        private XmlElement request;
        //----------------------------
        private XmlElement header;
        private XmlAttribute id;
        private XmlAttribute local;
        private XmlAttribute caja;
        private XmlAttribute operador;
        //----------------------------
        private XmlElement tx_req;
        private XmlAttribute cod_bar;
        private XmlAttribute fecha_serv;
        private XmlAttribute hora_serv;

        public XmlQC()
        {
            //-------------------------------------------------------------------------------
            writer = new XmlDocument();
            // Create XML declaration
            declaration = writer.CreateNode(XmlNodeType.XmlDeclaration, null, null);            
            writer.AppendChild(declaration);

            // Make the root element first
            request = writer.CreateElement("request");
            writer.AppendChild(request);

            //-------------------------------------------------------------------------------
                     
            header = writer.CreateElement("header");
            header.AppendChild(header);

            id = writer.CreateAttribute("id");
            id.Value = "0001";
            header.Attributes.Append(id);

            caja = writer.CreateAttribute("caja");
            caja.InnerText = "La Caja Seguros";
            header.Attributes.Append(caja);

            local = writer.CreateAttribute("local");
            local.InnerText = "tuvieja";
            header.Attributes.Append(local);

            //-------------------------------------------------------------------------------

            tx_req = writer.CreateElement("tx_req");
            request.AppendChild(tx_req);

            cod_bar = writer.CreateAttribute("cod_bar");
            cod_bar.Value = "zaraza";
            tx_req.Attributes.Append(cod_bar);

            fecha_serv = writer.CreateAttribute("fecha_serv");
            fecha_serv.Value = "Fecha";
            tx_req.Attributes.Append(fecha_serv);

            hora_serv = writer.CreateAttribute("hora_serv");
            hora_serv.Value = "Hora";
            tx_req.Attributes.Append(hora_serv);
        }


        public void save(string path)
        {
            writer.Save(path);
        }    
    }
}
